package com.study.aidada.mapper;

import com.study.aidada.model.dto.statistics.AppAnswerCountDTO;
import com.study.aidada.model.dto.statistics.AppAnswerResultCountDTO;
import com.study.aidada.model.entity.UserAnswer;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author asus
 * @description 针对表【user_answer(用户答题记录)】的数据库操作Mapper
 * @createDate 2024-06-12 13:45:48
 * @Entity com.study.aidada.model.entity.UserAnswer
 */
public interface UserAnswerMapper extends BaseMapper<UserAnswer> {
    @Select("select appId,COUNT(userId) as answerCount from user_answer\n" +
            "    group by appId order by answerCount desc limit 10;")
    List<AppAnswerCountDTO> doAppAnswerCount();


    @Select("select resultName, COUNT(resultName) as resultCount\n" +
            "from user_answer\n" +
            "where appId = #{appId}\n" +
            "group by resultName\n" +
            "order by resultCount desc;")
    List<AppAnswerResultCountDTO> doAppAnswerResultCount(Long appId);
}




